package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Collect;
import cn.wolfcode.trip.base.domain.Strategy;
import cn.wolfcode.trip.base.mapper.CollectMapper;
import cn.wolfcode.trip.base.query.SearcheObject;
import cn.wolfcode.trip.base.service.ICollectService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollectServiceImpl implements ICollectService {

    @Autowired
    private CollectMapper collectMapper;

    @Override
    public void delete(Long strategydetailId) {
        collectMapper.delete(strategydetailId);
    }

    @Override
    public void save(Collect record) {
        collectMapper.insert(record);
    }

    @Override
    public Collect get(Long strategydetailId) {
        return collectMapper.get(strategydetailId);
    }

    @Override
    public Collect get2(Long userId, Long strategydetailId) {
        return collectMapper.get2(userId,strategydetailId);
    }

    @Override
    public int selectForCount() {
        return collectMapper.selectForCount();
    }

    @Override
    public PageInfo query(SearcheObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Collect> list = collectMapper.selectForList(qo);
        return new PageInfo(list);
    }

}
